package yxy.cherry.battle.module.affix.buff;

import yxy.cherry.battle.Battle;
import yxy.cherry.battle.Fighter;
import yxy.cherry.battle.module.PropertyData;
import yxy.cherry.battle.module.PropertyType;
import yxy.cherry.battle.module.affix.AffixFactory.BuffTypeEnum;
import yxy.cherry.battle.module.affix.Buff;
import yxy.cherry.battle.module.affix.BuffType;
import yxy.cherry.battle.module.record.stream.RecordStream39ChangeAttribute;
import yxy.cherry.battle.module.record.stream.RecordStream_SKL;
import yxy.cherry.data.bean.skill;

/** 属性加 */
@BuffType(Type = BuffTypeEnum.属性加固定值)
public class Affix_66_属性加固定值 extends Buff {

	private PropertyType get属性类型1() {
		return PropertyType.forNumber(getParam(0));
	}

	private int get属性增加1() {
		return getParam(1);
	}

	private PropertyType get属性类型2() {
		return PropertyType.forNumber(getParam(2));
	}

	private int get属性增加2() {
		return getParam(3);
	}

	public Affix_66_属性加固定值(Fighter source, Fighter target, skill skilldata, int[] params) {
		super(source, target, skilldata, params);
	}

	@Override
	public boolean exec(Fighter source, Fighter target) {
		PropertyType 属性类型1 = get属性类型1();
		PropertyType 属性类型2 = get属性类型2();
		int attribute1 = 0;
		int attribute2 = 0;
		if(属性类型1 != null){attribute1 = 属性类型1.getNumber();}
		if(属性类型2 != null){attribute2 = 属性类型2.getNumber();}

		//纵向叠加参数
		int overlay = 1;
		if(getOverlayMax() > 0){overlay = getOverlay();}

		PropertyData propertyData = new PropertyData();
		boolean set = false;
		long addValue1 = get属性增加1() * overlay;
		long addValue2 = get属性增加2() * overlay;
		if (属性类型1 != null && addValue1 > 0) {
			propertyData.setValue(属性类型1, addValue1);
			set = true;
		}
		if (属性类型2 != null && addValue2 > 0) {
			propertyData.setValue(属性类型2, addValue2);
			set = true;
		}
		if (set) {
			setPropertyData(propertyData);
		}

		getRecord().stream(new RecordStream_SKL(source,this.getSkilldata().getId())).record();
		getRecord().stream(new RecordStream39ChangeAttribute(target,this,attribute1,addValue1,attribute2,addValue2)).record();
		Battle.battleLogger(6,"属性加固定值：目标："+target.getName()+"属性1："+attribute1+"增加值："+addValue1+"属性2："+attribute2+"增加值："+addValue2);
		return true;
	}

	@Override
	public BuffType getBuffType() {
		return BuffType.属性加效果;
	}

	@Override
	public BuffStateType getBuffStateType() {
		return BuffStateType.属性加状态;
	}
}